Simplify imports in SocketAddresses.swift - #3696
Open
glbrntt wants to merge 3 commits into
Open
Conversation
Motivation: The module map for glibc is broken which can lead libc symbols being attributed to the wrong module. In NIO, SocketAddresses.swift imports CNIOLinux (and friends) but, as far as I can tell, doesn't use any of their symbols directly. The result is that various libc symbols incorrectly get attributed to CNIOLinux and compilation can fail for downstream packages with member import visibility checks enabled. See also: swiftlang/swift#85427 Modifications: - Remove the CNIO* imports from SocketAddresses.swift as they appear to be unused - Simplify the imoport block Result: Can build grpc with member import visibility checks enabled.
Contributor
Author
|
This is by no means a complete fix: it just unblocks the issue we're currently seeing in gRPC. I'm also a bit nervous about there being unintended consequences of this change. This PR ran into this issue: grpc/grpc-swift-nio-transport#186 |
fabianfett
approved these changes
Aug 11, 2026
| import CNIOFreeBSD | ||
| #elseif os(OpenBSD) | ||
| @preconcurrency import Glibc | ||
| import CNIOOpenBSD |
Member
There was a problem hiding this comment.
Is the CNIOOpenBSD not needed anymore? Well CI should show.
Contributor
Author
There was a problem hiding this comment.
There are no CNIOOpenBSD_* symbols in this file which makes me think it isn't.(All symbols in the header have that prefix, see here.)
It's the same for CNIOLinux: it appears as if the import isn't necessary here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
The module map for glibc is broken which can lead libc symbols being attributed to the wrong module. In NIO, SocketAddresses.swift imports CNIOLinux (and friends) but, as far as I can tell, doesn't use any of their symbols directly. The result is that various libc symbols incorrectly get attributed to CNIOLinux and compilation can fail for downstream packages with member import visibility checks enabled.
See also: swiftlang/swift#85427
Modifications:
Result:
Can build grpc with member import visibility checks enabled.